export function debounce(fn: Function, wait: number) {
  let timer: number | null = null
  return function() {
    if(timer) {
      clearTimeout(timer)
      timer = null
    }
    timer = setTimeout(fn, wait)
  }
}

export const animationsClass = (classNames: string[]) => {
  if(classNames?.length) {
    return `animate__animated animate__${classNames[0]}`
  }
  return ''
}

export function getAttrs(attrList: IAttr[]) {
  const map = <{[k: string]: any}>{}
  for(let attr of attrList) {
    map[attr.name] = attr.value
  }
  return map
}